$('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
	if ($(window).width() <= 750) {
		$('.navbar-collapse').collapse('toggle');
	}
});

$("form").submit(function(e) {
	e.preventDefault();
});

$('#userLoginButton').click(function() {
	var username = $('#userLoginAccount').val();
	if (username != '' && $('#userLoginPasswd').val() != '') {
		$.ajax({
			type : 'post',
			url : '/schoolBus/client/getPassenger',
			data : $('#userLoginForm').serialize(),
			dataType : 'json',
			success : function(data) {
				if (data.flag) {
					window.location.replace('/schoolBus/client/cHome');
				} else {
					$('#loginAndRegisterLabel').text('登录失败，请重新登录！');
					$('#loginAndRegister').modal('show');
				}
			}
		});
	} else {
		$('#loginAndRegisterLabel').text('必填项不能够为空！');
		$('#loginAndRegister').modal('show');
	}
});

$('#userRegisterButton').click(function() {
	var username = $('#userRegisterAccount').val();
	if (username != '' && $('#userRegisterPasswd').val() != '') {
		if ($('#userRegisterPasswd').val() == $('#userRePasswd').val()) {
			$.ajax({
				type : 'post',
				url : '/schoolBus/client/addPassenger',
				data : $('#userRegisterForm').serialize(),
				dataType : 'json',
				success : function(data) {
					if (data.flag) {
						window.location.replace('/schoolBus/client/cLogin');
					} else {
						$('#loginAndRegisterLabel').text('注册失败，请重新注册！');
						$('#loginAndRegister').modal('show');
					}
				}
			});
		} else {
			$('#loginAndRegisterLabel').text('密码输入不一致！');
			$('#loginAndRegister').modal('show');
		}
	} else {
		$('#loginAndRegisterLabel').text('必填项不能够为空！');
		$('#loginAndRegister').modal('show');
	}
});